package ocean.chinacraft.common.world.gen;

import net.minecraft.util.RegistryKey;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import ocean.chinacraft.common.world.gen.features.ModConfiguredFeatures;

import java.util.List;
import java.util.Set;
import java.util.function.Supplier;

/**
 * 花生成
 *
 * @author zhang
 * @since 2021/12/2
 */
public class ModFlowersGeneration {

    public static void generateTrees(final BiomeLoadingEvent event) {
        if (event.getName() != null) {
            RegistryKey<Biome> key = RegistryKey.create(Registry.BIOME_REGISTRY, event.getName());
            Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(key);
            List<Supplier<ConfiguredFeature<?, ?>>> base =
                    event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION);
            if (types.contains(BiomeDictionary.Type.MOUNTAIN)) {
                base.add(() -> ModConfiguredFeatures.AZALEA_FLOWER);
                base.add(() -> ModConfiguredFeatures.PEONY_FLOWER);
            }
            if (types.contains(BiomeDictionary.Type.PLAINS)) {
                base.add(() -> ModConfiguredFeatures.CHRYSANTHEMUM_FLOWER);
            }
        }
    }
}
